package com.qushiyun.devops.admin.sync.data.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qushiyun.devops.admin.sync.data.mapper.ConditionConfigMapper;
import com.qushiyun.devops.admin.sync.data.po.ConditionConfig;
import com.qushiyun.devops.admin.sync.data.service.ConditionConfigService;
import com.qushiyun.devops.common.framework.mybatis.page.vo.PageVO;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * 同步条件
 *
 * @author zhouzx
 */
@Service
public class ConditionConfigServiceImpl extends ServiceImpl<ConditionConfigMapper, ConditionConfig> implements ConditionConfigService {


    /**
     * 分页列表
     */
    @Override
    public PageVO<ConditionConfig> pageList(PageDTO page, ConditionConfig conn) {
        LambdaQueryWrapper<ConditionConfig> wrapper = Wrappers.lambdaQuery(ConditionConfig.class)
            .like(!StringUtils.isEmpty(conn.getName()), ConditionConfig::getName, conn.getName());
        IPage<ConditionConfig> pageResult = baseMapper.selectPage(page, wrapper);
        PageVO<ConditionConfig> result = new PageVO<>();
        result.setTotal(pageResult.getTotal());
        result.setList(pageResult.getRecords());
        return result;
    }


}
